@@ -10,4 +10,13 @@ class ApplicationController < ActionController::Base |
||
| 10 | 10 |
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :location) }
|
| 11 | 11 |
end |
| 12 | 12 |
|
| 13 |
+ def after_sign_in_path_for(resource) |
|
| 14 |
+ sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http') |
|
| 15 |
+ if request.referer == sign_in_url |
|
| 16 |
+ missions_path |
|
| 17 |
+ else |
|
| 18 |
+ missions_path |
|
| 19 |
+ end |
|
| 20 |
+ end |
|
| 21 |
+ |
|
| 13 | 22 |
end |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 |
module ApplicationHelper |
| 2 | 2 |
|
| 3 |
- def link_to_add_fields(name, f, association) |
|
| 3 |
+ def link_to_add_fields(name, f, association, classes = '') |
|
| 4 | 4 |
new_object = f.object.send(association).klass.new |
| 5 | 5 |
id = new_object.object_id |
| 6 | 6 |
fields = f.fields_for(association, new_object, child_index: id) do |builder| |
| 7 | 7 |
render(association.to_s.singularize + "_form", f: builder) |
| 8 | 8 |
end |
| 9 |
- link_to(name, '', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
|
|
| 9 |
+ link_to(name, '', class: "add_fields " + classes.to_s, data: {id: id, fields: fields.gsub("\n", "")})
|
|
| 10 | 10 |
end |
| 11 | 11 |
|
| 12 | 12 |
end |
@@ -7,8 +7,10 @@ class Mission < ActiveRecord::Base |
||
| 7 | 7 |
def validade_completion |
| 8 | 8 |
mission_completed = true |
| 9 | 9 |
self.mission_agents.each do |agent| |
| 10 |
- if agent.get_invite.status != 'Completed' |
|
| 11 |
- mission_completed = false |
|
| 10 |
+ if agent.get_invite != nil |
|
| 11 |
+ if agent.get_invite.status != 'Completed' |
|
| 12 |
+ mission_completed = false |
|
| 13 |
+ end |
|
| 12 | 14 |
end |
| 13 | 15 |
end |
| 14 | 16 |
if mission_completed |
@@ -18,6 +20,11 @@ class Mission < ActiveRecord::Base |
||
| 18 | 20 |
end |
| 19 | 21 |
|
| 20 | 22 |
def has_agent_been_assigned(user) |
| 23 |
+ # Dont assign the owner of a mission as one of its agents |
|
| 24 |
+ if user == self.owner |
|
| 25 |
+ return true |
|
| 26 |
+ end |
|
| 27 |
+ # Iterate thru all mission agents and check if user has been asigned |
|
| 21 | 28 |
self.mission_agents.each do |agent| |
| 22 | 29 |
if agent.user != user |
| 23 | 30 |
agent.mission_agent_invites.each do |invite| |
@@ -9,7 +9,7 @@ class MissionAgent < ActiveRecord::Base |
||
| 9 | 9 |
accepts_nested_attributes_for :mission_agent_invites |
| 10 | 10 |
|
| 11 | 11 |
def get_invite |
| 12 |
- return self.mission_agent_invites.where(:user => self.user).last |
|
| 12 |
+ return self.mission_agent_invites.where(:user_id => self.user_id).last |
|
| 13 | 13 |
end |
| 14 | 14 |
|
| 15 | 15 |
def assign_agent |
@@ -20,9 +20,11 @@ class MissionAgent < ActiveRecord::Base |
||
| 20 | 20 |
available_agents << u |
| 21 | 21 |
end |
| 22 | 22 |
end |
| 23 |
- new_agent = available_agents[rand(available_agents.length)] |
|
| 24 |
- self.update(:user => new_agent) |
|
| 25 |
- self.mission_agent_invites.create!(:user => new_agent, :status => 'Invited') |
|
| 23 |
+ if available_agents.length > 0 |
|
| 24 |
+ new_agent = available_agents[rand(available_agents.length)] |
|
| 25 |
+ self.update(:user => new_agent) |
|
| 26 |
+ self.mission_agent_invites.create!(:user => new_agent, :status => 'Invited') |
|
| 27 |
+ end |
|
| 26 | 28 |
end |
| 27 | 29 |
|
| 28 | 30 |
end |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 |
<%= f.fields_for :mission_agents, MissionAgent.order('created_at ASC').find_all_by_mission_id(@mission) do |agent_builder| %>
|
| 13 | 13 |
<%= render 'mission_agent_form', f: agent_builder %> |
| 14 | 14 |
<%end%> |
| 15 |
- <%= link_to_add_fields "Add Agent", f, :mission_agents %> |
|
| 15 |
+ <%= link_to_add_fields "Add Agent", f, :mission_agents, 'btn' %> |
|
| 16 | 16 |
|
| 17 | 17 |
</div> |
| 18 | 18 |
|
@@ -4,10 +4,10 @@ |
||
| 4 | 4 |
<%= f.label :description, "Description"%><br/> |
| 5 | 5 |
<%= f.text_area :description%><br/> |
| 6 | 6 |
<%= f.hidden_field :_destroy%> |
| 7 |
- <%= link_to "remove", '#', class: "remove_fields"%> |
|
| 7 |
+ <%= link_to "remove", '#', class: "remove_fields btn"%> |
|
| 8 | 8 |
<%= f.fields_for :mission_agent_steps, MissionAgentStep.where(:mission_agent_id => f.object.id).order(:step => :asc), show_empty: true do |step_builder| %> |
| 9 | 9 |
<%= render 'mission_agent_step_form', f: step_builder %> |
| 10 | 10 |
<%end%> |
| 11 |
- <%= link_to_add_fields "Add Step", f, :mission_agent_steps %> |
|
| 11 |
+ <%= link_to_add_fields "Add Step", f, :mission_agent_steps, 'btn' %> |
|
| 12 | 12 |
<% @agent = @agent + 1 %> |
| 13 | 13 |
</fieldset> |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 |
<% if @mission.mission_agents.length > 0 %> |
| 18 | 18 |
<div class="accordion" id="accordion_agents"> |
| 19 | 19 |
<% @agent_number = 1 %> |
| 20 |
- <% @mission.mission_agents.each do |agent| %> |
|
| 20 |
+ <% @mission.mission_agents.order(:created_at => :asc).each do |agent| %> |
|
| 21 | 21 |
<% if agent.mission_agent_invites.last != nil %> |
| 22 | 22 |
<% if agent.mission_agent_invites.last.status == 'accepted' %> |
| 23 | 23 |
<% @status_label = 'label-success'%> |
@@ -64,27 +64,33 @@ |
||
| 64 | 64 |
</div> |
| 65 | 65 |
<div id="collapse_<%= agent.id %>" class="accordion-body collapse <% if @agent_status == 'missing' || @agent_status == 'empty' || @agent_status == 'closed' %> out <% else %> in <% end %>"> |
| 66 | 66 |
<div class="accordion-inner"> |
| 67 |
- <div class="row-fluid"> |
|
| 68 |
- <ul class="thumbnails"> |
|
| 69 |
- <% @step = 1 %> |
|
| 70 |
- <% agent.mission_agent_steps.order(:step => :asc).each do |step| %> |
|
| 71 |
- <li class="span4"> |
|
| 72 |
- <div class="thumbnail" style= "padding: 5px;"> |
|
| 73 |
- <h3 style= "padding: 5px; margin-top: 0px;">Step <%= @step %> <%= render 'mission_agent_step_status', :step => step %></h3> |
|
| 74 |
- <p style= "padding: 5px; height: 50px;"><%= step.description %></p> |
|
| 75 |
- <% if step.status == 'Waiting Validation'%> |
|
| 76 |
- <div class="well well-small" style="margin-bottom: 0px; text-align: center; height: 90px;"> |
|
| 77 |
- <p style="height: 60px"><strong>Response:</strong> <%= step.proof %></p> |
|
| 78 |
- <div style=" margin-top: 10px"> |
|
| 79 |
- <%= link_to 'Invalidade', step_invalidate_check_path(step.id), :class => 'btn btn-danger btn-mini' %> |
|
| 80 |
- <%= link_to 'Validade', step_validate_check_path(step.id), :class => 'btn btn-success btn-mini', :style => 'margin-right: 5px;' %> |
|
| 81 |
- </div> |
|
| 82 |
- </div> |
|
| 83 |
- <% end %> |
|
| 84 |
- </li> |
|
| 85 |
- <% @step = @step + 1 %> |
|
| 67 |
+ <% @step = 1 %> |
|
| 68 |
+ <% @line_step = 0%> |
|
| 69 |
+ <% agent.mission_agent_steps.order(:created_at => :asc).each do |step| %> |
|
| 70 |
+ <% if @line_step == 0 %> |
|
| 71 |
+ <div class="row-fluid"><ul class="thumbnails"> |
|
| 86 | 72 |
<% end %> |
| 87 |
- </ul> |
|
| 73 |
+ <li class="span4"> |
|
| 74 |
+ <div class="thumbnail" style= "padding: 5px;"> |
|
| 75 |
+ <h3 style= "padding: 5px; margin-top: 0px;">Step <%= @step %> <%= render 'mission_agent_step_status', :step => step %></h3> |
|
| 76 |
+ <p style= "padding: 5px; height: 50px;"><%= step.description %></p> |
|
| 77 |
+ <% if step.status == 'Waiting Validation'%> |
|
| 78 |
+ <div class="well well-small" style="margin-bottom: 0px; text-align: center; height: 90px;"> |
|
| 79 |
+ <p style="height: 60px"><strong>Response:</strong> <%= step.proof %></p> |
|
| 80 |
+ <div style=" margin-top: 10px"> |
|
| 81 |
+ <%= link_to 'Invalidade', step_invalidate_check_path(step.id), :class => 'btn btn-danger btn-mini' %> |
|
| 82 |
+ <%= link_to 'Validade', step_validate_check_path(step.id), :class => 'btn btn-success btn-mini', :style => 'margin-right: 5px;' %> |
|
| 83 |
+ </div> |
|
| 84 |
+ </div> |
|
| 85 |
+ <% end %> |
|
| 86 |
+ </li> |
|
| 87 |
+ <% @step = @step + 1 %> |
|
| 88 |
+ <% @line_step = @line_step + 1%> |
|
| 89 |
+ <% if @line_step == 3 %> |
|
| 90 |
+ <% @line_step = 0%> |
|
| 91 |
+ </div></ul> |
|
| 92 |
+ <% end %> |
|
| 93 |
+ <% end %> |
|
| 88 | 94 |
</div> |
| 89 | 95 |
</div> |
| 90 | 96 |
</div> |
@@ -127,6 +127,7 @@ rails g migration AddValidationToMissionAgentStep validated:boolean validated_by |
||
| 127 | 127 |
|
| 128 | 128 |
``` |
| 129 | 129 |
|
| 130 |
+ |
|
| 130 | 131 |
## Badges/Trophies/Perks |
| 131 | 132 |
|
| 132 | 133 |
- Recruiter |
@@ -214,13 +215,7 @@ rails g migration AddValidationToMissionAgentStep validated:boolean validated_by |
||
| 214 | 215 |
|
| 215 | 216 |
## Bugs |
| 216 | 217 |
|
| 217 |
-- After Mission Launch, agents that were not found are shown as invited |
|
| 218 |
-- Mission in dashboard that the owner is an agent needs a button for "mission details" |
|
| 219 |
-- Steps are out of order in mission control |
|
| 220 |
-- Agent steps layout in mission control with more than 3 items |
|
| 221 |
-- Sign In redirects to home page instead of mission dashboard |
|
| 222 |
-- (SERIOUS) Step validation in mission control. Rails server crashes after accepting anwser |
|
| 223 |
-- Do not assign the owner of a mission as one of its agents |
|
| 218 |
+**No bugs found for now...* |
|
| 224 | 219 |
|
| 225 | 220 |
## Code Clipper |
| 226 | 221 |
|